<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .box {
        width: 300px;
        height: 300px;
        border: 1px solid;
      }

      .bg {
        background-color: green;
      }
    </style>
  </head>
  <body>
    <input autofocus />
    <div class="box"></div>
    <button type="button" onclick="change()">change</button>
    <button type="button" onclick="remove()">remove</button>

    <script>
      let box = document.querySelector(".box");
      window.onload = () => {
        function change() {
          // 操作 class
          // console.log(box.classList);
          // box.className = box.className + " bg";
          // box.classList.add("bg");

          box.style.backgroundColor = "blue";
        }

        function remove() {
          box.classList.remove("bg");
        }

        //   box.addEventListener("click", () => {
        //     console.log("点击了 div");
        //   });

        //   box.onclick = () => {
        //     console.log(222);
        //   };
      };
    </script>
  </body>
</html>
